package me.zk;

import java.util.Optional;

/**
 * @Author: zhang kai
 * @Date: 2022/06/22
 * @Description:
 */
public class OptionalDemo {
    public static void main(String[] args) {
        Optional<Integer> op1 = Optional.ofNullable(null);
        Optional<Integer> op2 = Optional.of(2);
        sum(op1,op2);
    }
    private static void sum(Optional<Integer> a, Optional<Integer> b){
        System.out.println("参数a是否存在：" + a.isPresent());
        System.out.println("参数b是否存在：" + b.isPresent());
        System.out.println(a.orElse(9) + b.orElse(10));
    }
}
